package demo.huangli.mydemosnew.logic_set_1.bolts;

import android.content.Intent;

import demo.huangli.mydemosnew.BaseListActivity;

/**
 * Created by huangli on 17/12/29.
 */

public class BoltsActivity extends BaseListActivity {

    public static String TAG = "BoltsActivity";


    @Override
    public void initItems() {
        addListviewItem("在当前线程执行Task", new ItemClickListener() {
            @Override
            public void itemClicked() {
                BoltsHelper.callOnCurThread();
            }
        });
        addListviewItem("在后台线程执行Task", new ItemClickListener() {
            @Override
            public void itemClicked() {
                BoltsHelper.callOnBackGroundThread();
            }
        });
        addListviewItem("在Ui线程执行Task", new ItemClickListener() {
            @Override
            public void itemClicked() {
                BoltsHelper.callOnUiThread();
            }
        });
        addListviewItem("延迟执行Task", new ItemClickListener() {
            @Override
            public void itemClicked() {
                BoltsHelper.callDelay();
            }
        });
        addListviewItem("Chaining Tasks", new ItemClickListener() {
            @Override
            public void itemClicked() {
                BoltsHelper.callChainingTasks();
            }
        });
        addListviewItem("Group Tasks", new ItemClickListener() {
            @Override
            public void itemClicked() {
                BoltsHelper.callGroupTasks();
            }
        });
        addListviewItem("Tasks in Parallel", new ItemClickListener() {
            @Override
            public void itemClicked() {
                BoltsHelper.callTasksInParallel();
            }
        });
        addListviewItem("Tasks in Serial", new ItemClickListener() {
            @Override
            public void itemClicked() {
                BoltsHelper.callTasksInSerial();
            }
        });
        addListviewItem("Error Handling", new ItemClickListener() {
            @Override
            public void itemClicked() {
                BoltsHelper.errorHandling();
            }
        });
        addListviewItem("用Bolts去模拟一个登录流程", new ItemClickListener() {
            @Override
            public void itemClicked() {
                BoltsHelper.login();
            }
        });
        addListviewItem("自定义TaskCompletionSource", new ItemClickListener() {
            @Override
            public void itemClicked() {
                BoltsHelper.createTask();
            }
        });
        addListviewItem("Capturing Variables", new ItemClickListener() {
            @Override
            public void itemClicked() {
                BoltsHelper.captureVariables();
            }
        });
        addListviewItem("取消一个正在执行的Task", new ItemClickListener() {
            @Override
            public void itemClicked() {
                Intent intent = new Intent(BoltsActivity.this,CancelTaskActivity.class);
                startActivity(intent);
            }
        });
    }
}
